<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        body {
            background-color: antiquewhite;

        }


        li {
            list-style: none;
        }

        ul {
            padding: 0;
            margin: 0;
        }

        .box {
            overflow: hidden;
        }

        .list {
            width: calc(25% - 1.5rem / 4);
            float: left;
            margin-bottom: .5rem;
        }

        .list:not(:nth-child(4n + 1)) {
            margin-left: .5rem;
        }

        .cover {
            /* padding的百分比计算值都是相对于宽度计算的，哪怕是垂直方向。 */
            padding: 100% 100% 0 0;
            position: relative;
        }

        .cover img {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
    </style>
</head>

<body>
    <!-- 传统方法需要三层元素，并且利用的是padding的百分比计算值是相对于宽度计算的特性。 -->
    <ul class="box">
        <li class="list">
            <div class="cover">
                <img src="../images/1.jpg" />
            </div>
        </li>
        <li class="list">
            <div class="cover">
                <img src="../images/1.jpg" />
            </div>
        </li>
        <li class="list">
            <div class="cover">
                <img src="../images/1.jpg" />
            </div>
        </li>
        <li class="list">
            <div class="cover">
                <img src="../images/1.jpg" />
            </div>
        </li>
        <li class="list">
            <div class="cover">
                <img src="../images/1.jpg" />
            </div>
        </li>
        <li class="list">
            <div class="cover">
                <img src="../images/1.jpg" />
            </div>
        </li>
    </ul>


</body>

</html>